package blog.util.back;

import blog.entity.Consumer;
import blog.vo.common.ResponseVO;
import lombok.Data;
import org.springframework.ui.Model;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
@Data
public class ControllerUtil {
    public static String updateResultUrl(int result,String redirectUrl,Model model){
        switch (result){
            case 0:
                redirectUrl = "error";
                model.addAttribute("error",new ResponseVO<Consumer>(500,"修改失败",null));
                return redirectUrl;
            case 1:
                return redirectUrl;
        }
        return null;
    }

    public static String addResultUrl(int result,String redirectUrl,Model model){
        switch (result){
            case 0:
                redirectUrl = "error";
                model.addAttribute("error",new ResponseVO<Consumer>(500,"添加失败",null));
                return redirectUrl;
            case 1:
                return redirectUrl;
        }
        return null;
    }
}
